import io from 'socket.io-client'
const DEVELOPMENT_REQ_URL = 'https://dev.api.gmall.gaopeng.com'
const RELEASE_REQ_URL = 'https://qa.api.gmall.gaopeng.com'
const PRODUCTION_REQ_URL = 'https://api.gmall.wetax.com.cn'
const TOKEN_STORAGE_KEY = '__TOKEN_STORAGE_NAME__GMALL'

const PRE_CLIENT_DEV = 'gmall_dev_'
const PRE_CLIENT_REL = 'gmall_qa_'
const PRE_CLIENT_PROD = 'gmall_prod_'

const NAV_MENU = [
  {
    name: '数据概况',
    child: [
      {
        name: '实时罗盘',
        path: '/compass'
      },
      {
        name: '历史数据',
        path: '/history'
      }
    ]
  },
  {
    name: '顾客行为',
    child: [
      {
        name: '顾客动线',
        path: '/trajectory'
      },
      {
        name: '逛店时长',
        path: '/timeinshop'
      },
      {
        name: '逛店频率',
        path: '/shoptimes'
      }
    ]
  },
  {
    name: '顾客粘度',
    child: [
      {
        name: '活跃度',
        path: '/activeness'
      },
      {
        name: '活跃天数',
        path: '/dayactiveness'
      }
    ]
  },
  {
    name: '顾客挖掘',
    path: '/customer'
  },
  {
    name: '店铺管理',
    path: '/management'
  },
  {
    name: '设置',
    path: '/settings'
  }
]

const Config = {
  // req url
  DEVELOPMENT_REQ_URL,
  RELEASE_REQ_URL,
  PRODUCTION_REQ_URL,
  TOKEN_STORAGE_KEY,
  NAV_MENU,
  SOCKET_PORT: 7001,
  CURR_REQ_URL: process.env.NODE_ENV === 'production' ? 'https://api.gmall.gaopeng.com' : process.env.NODE_ENV === 'release' ? RELEASE_REQ_URL : DEVELOPMENT_REQ_URL,
  CURR_PRE_CLIENT: process.env.NODE_ENV === 'production' ? PRE_CLIENT_PROD : process.env.NODE_ENV === 'release' ? PRE_CLIENT_REL : PRE_CLIENT_DEV,
  // req header
  APP_ID: 1,
  APP_VER: '0.0.1',
  // code
  SUCCESS_CODE: 0,
  ERROR_CODE: -1,
  NOT_LOGGED: -1000,
  LOGIN_INFO_ERR: -2001,

  DEV_DEFAULT_SHOP_ID: 1,
  DEFAULT_AREA_TITLE: 'GMALL',
  NO_TOKEN_CANVIEW: {
    '/login': true,
    '/403': true,
    '/404': true
  },
  // websocket config
  ECHO_BASE: {
    broadcaster: 'socket.io',
    client: io
  },
  ECHO_EVENT_RTIME: '.real-time-stats.updated'
}

export default Config
